package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.GroupFans;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

public interface GroupFansMapper extends MyMapper<GroupFans> {

    @Select(value = "select * from t_group_fans t where t.employee_id = #{employeeId}")
    public List<GroupFans> findGroupFansByEmployeeId(Integer employeeId);

    @Delete(value = "delete from t_group_fans where group_id = #{groupId}")
    public void deleteByGroupId(Integer groupId);

    void deleteByGroupIdAndEmployeeId(@Param("groupId") Integer groupId, @Param("list") List<Integer> list);

    @Delete(value = "delete from t_group_fans where group_id =#{groupId} and b_fans_id = #{fansId}")
    void deleteByGroupIdAndFansId(@Param("groupId") Integer groupId, @Param("fansId") Integer fansId);

    @Select(value = "select * from t_group_fans where group_id =#{groupId}")
    List<GroupFans> getGroupFansByGroupId(Integer groupId);

    @Select(value = "select * from t_group_fans t where t.b_fans_id = #{fansId}")
    public List<GroupFans> findGroupFansByFansId(Integer fansId);

    @Select(value = "select count(t.group_id) from t_group_fans t where t.employee_id = #{employeeId} and " +
            "t.group_id = #{groupId}")
    Integer countByEmployeeIdAGroupId(@Param("employeeId") Integer employeeId, @Param("groupId") Integer groupId);

    List<GroupFans> findGroupFansByGroupId(List<Integer> ids);

    List<GroupFans> findGroupFansByGroupIdSet(Set<Integer> ids);

    List<GroupFans> listGroupFansByGroupId(@Param("groupId") Integer groupId);

    List<Integer> findEmployeeIdByNotGroupId(@Param("list")List<Integer> list,@Param("groupId") Integer groupId);

    List<Integer> findEmployeeIdsByGrouoId(@Param("groupId") Integer groupId);
}
